from playwright.sync_api import sync_playwright

# 节省代码量，使用with方法
with sync_playwright() as pw:
    # 打开Chrome浏览器
    browser = pw.chromium.launch(headless=False, executable_path=r"C:\Users\huhao\AppData\Local\Google\Chrome\Application\chrome.exe")
    page = browser.new_page()
    page.goto("https://cdn2.byhy.net/files/selenium/sample1.html")
    page.wait_for_timeout(1500)
    get_text = page.get_by_text("11").all_inner_texts()
    print(get_text)
    # lct先获取到page的#bottom值
    # lct = page.locator('#bottom span').all_inner_texts()
    # print(lct)
    # 而后再使用lct.locator去lct元素内部查找，没错，lct也能单独使用locator函数
    # print(lct.locator('span').all_inner_texts())

# 使用with方法就不需要手动关闭了


